package BIOtest05;

import java.io.*;
import java.net.Socket;

/**
 * 任意类型文件传输
 */
public class Client {
    public static void main(String[] args) {
        try( InputStream InputStream = new FileInputStream("C:/Intel/微信图片_20230519172932.jpg")){
            Socket socket = new Socket("127.0.0.1",9000);
            DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
            dataOutputStream.writeUTF(".jpg");
            byte[] bytes = new byte[1024];
            int len = 0;
            while ((len = InputStream.read(bytes))!=-1){
                System.out.println("进入循环了");
                dataOutputStream.write(bytes,0,len);
            }
            dataOutputStream.flush();
            socket.shutdownOutput();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

}
